package com.example.enterprise


import androidx.activity.viewModels
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.example.common.view.view.BaseMvvmActivity
import com.example.enterprise.databinding.ActivityEnterpriseAddBinding
import com.example.enterprise.entity.EnterpriseEntityItem
import com.example.enterprise.entity.HouseEntityItem
import com.example.enterprise.vm.EnterpriseAddViewModel

@Route(path = "/enterprise/EnterpriseAddActivity")
class EnterpriseAddActivity : BaseMvvmActivity<ActivityEnterpriseAddBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_enterprise_add
    private val enterpriseAddViewModel: EnterpriseAddViewModel by viewModels()
    override fun initView() {
        super.initView()
        mDataBinding.btn.setOnClickListener {
            val houseEntityItem = HouseEntityItem(
                applicationArea = 123, //申请区域
                applicationNumber = "RZ${mDataBinding.contactMethod.text}",// 申请编号
                contactMethod = mDataBinding.contactMethod.text.toString().toLong(),// 联系方式
                contactName = mDataBinding.contactName.text.toString(),// 联系人姓名
                documents = listOf(),// 文档列表
                enterpriseName = mDataBinding.enterpriseName.text.toString(),//企业名称
                enterpriseProfileId = 1,//企业档案ID
                entryPersonnel = mDataBinding.entryPersonnel.text.toString().toInt(),// 录入人员
                entryTime = mDataBinding.entryTime.text.toString(),//录入时间
                id = 0,// 实体ID
                processingSteps = listOf() ,// 处理步骤列表
                status = "新建",// 状态
            )
            enterpriseAddViewModel.postMerchant(houseEntityItem)
        }
        enterpriseAddViewModel.mSuccessLiveData.observe(this){
            ToastUtils.showLong("添加成功")
            finish()
        }
        enterpriseAddViewModel.mErrorLiveData.observe(this){
            ToastUtils.showLong(it)
        }
    }

}